#pragma once

#include <cmath>
#include <cstdio>
#include <cstring>
#include <glad/gl-headers.h>
#define GLFW_NO_GLU 1
#ifndef USE_GLES
#define GLFW_INCLUDE_GLCOREARB 1
#endif
#include <GLFW/glfw3.h>


#include "log.h"

class Node;
class PerfWindow
{
public:
    static PerfWindow *get();
    virtual ~PerfWindow();
public:
    void setWindowSize(int width, int height);
    void setWindowTitle(const char *title);
    void setWindowMsaa(bool enable);
    void setOpenGLVersion(unsigned int major, unsigned int minor);

    void setRenderNode(Node *node);

    void swapBuffer();
    bool processInput();

    //static int majorVersion;
    //static int minorVersion;
    static int glVersion;
    static bool isOpenGLSupported();
    static void checBestGLVersion();

    static bool fullScreen;
    static bool msaaFlag;
    static int windowWidth;
    static int windowHeight;
    bool create();
    bool destory();
private:
    GLFWwindow *glfwWindow = nullptr;
    static PerfWindow *instanceWindow;
    static void onWindowResized(GLFWwindow *window, int width, int height);

    PerfWindow();
    Node *renderNode = nullptr;
    int width;
    int height;
};

